﻿#include <iostream>
#include <queue>
#include <vector>
using namespace std;
#include "Priority_Queue.h"
using namespace My_Priority_Queue;
//优先级队列 priority_queue
void Test_Priority_Queue()
{
	//插入删除效率 O(logn)
	//std::priority_queue<int> pq;//大堆(默认)
	//std::priority_queue<int,vector<int>,less<int>> pq;//大堆
	std::priority_queue<int, vector<int>, greater<int>> pq;//小堆
	pq.push(1);
	pq.push(5);
	pq.push(9);
	pq.push(10);
	pq.push(0);
	pq.push(3);
	pq.push(4);
	pq.push(2);
	while (!pq.empty())
	{
		cout << pq.top() << " ";
		pq.pop();
	}
	cout << endl;
}

void Test1_My_Priority_Queue()
{
	//My_Priority_Queue::priority_queue<int> pq;
	My_Priority_Queue::priority_queue<int, vector<int>, Less<int>> pq;
	//My_Priority_Queue::priority_queue<int, vector<int>, Greater<int>> pq;
	pq.push(1);
	pq.push(5);
	pq.push(9);
	pq.push(10);
	pq.push(0);
	pq.push(3);
	pq.push(4);
	pq.push(2);
	while (!pq.empty())
	{
		cout << pq.top() << " ";
		pq.pop();
	}
	cout << endl;

}
void Test2_My_Priority_Queue()
{
	vector<int> v;
	v.push_back(1);
	v.push_back(5);
	v.push_back(9);
	v.push_back(10);
	v.push_back(0);
	v.push_back(3);
	v.push_back(4);
	v.push_back(2);
	My_Priority_Queue::priority_queue<int, vector<int>, Greater<int>> pq(v.begin(), v.end());
	while (!pq.empty())
	{
		cout << pq.top() << " ";
		pq.pop();
	}
	cout << endl;
}
int main()
{

	Test_Priority_Queue();
	Test1_My_Priority_Queue();
	Test2_My_Priority_Queue();
	return 0;
}